//
//  AppDelegate.m
//  CareLinkApp_iOS19
//
//  Created by 刘家强 on 16/8/21.
//  Copyright © 2016年 Seven Team. All rights reserved.
//

#import "AFNetworkActivityIndicatorManager.h"
#import "AppDelegate.h"
#import "CLAEViewController.h"
#import "CLHelpAndSet.h"
#import <SMS_SDK/SMSSDK.h>
#import <TencentOpenAPI/TencentOAuth.h>
@interface AppDelegate ()

@property (nonatomic, strong) CLDataManager *manager;

@end

@implementation AppDelegate

/**
 公益活动 网页 : http://202.106.210.115:18080/hyde-pluto-h360/nt/appEntrance.htm
 用户协议
 加号服务管理患者版
 
 新浪微博
 [appInfo SSDKSetupSinaWeiboByAppKey:@"568898243"
 appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
 redirectUri:@"http://www.sharesdk.cn"
 authType:SSDKAuthTypeBoth];
 
 */
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
    return [TencentOAuth HandleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    return [TencentOAuth HandleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

     //初始化应用，appKey和appSecret从后台申请得
    
    
    // 显示流量监控
    [AFNetworkActivityIndicatorManager sharedManager].enabled = true;

    // 1. 初始化window
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    // 1.1
    //    self.window.backgroundColor = [UIColor whiteColor];
//    [SMSSDK registerApp:@"164af73a4d46a"
//             withSecret:@"d9997efbbf455ba3d4d71806baad0584"];
     [SMSSDK registerApp:@"166afd9a969e6" withSecret:@"f67f72d2cee11e6cad01958b65d573b6"];
    
    // 2. 设置根控制器
    self.window.rootViewController = [NSClassFromString(@"CLDrawViewController") new];

    [self.window makeKeyAndVisible];

    /*
     当程序启动时
     1、判断launchOptions字典内的UIApplicationLaunchOptionsShortcutItemKey是否为空
     2、当不为空时,application:didFinishLaunchWithOptions方法返回NO，否则返回YES
     3、在application:performActionForShortcutItem:completionHandler方法内处理点击事件
     */

    //     [self configShortCutItems];
    
    self.manager = [CLDataManager sharedManager];
    

    return YES;
}

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
    if ([shortcutItem.localizedTitle isEqualToString:@"点我"]) {
        self.window.rootViewController.view.backgroundColor = [UIColor yellowColor];
    } else if ([shortcutItem.localizedTitle isEqualToString:@"么么哒"]) {
        self.window.rootViewController.view.backgroundColor = [UIColor redColor];
    }
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
